<html>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(t => {
  var iframe = document.createElement('iframe');
  iframe.src = '/resources/redirect.php?url=data:text/plain,redirected1';
  iframe.onload = () => {
    assert_equals(iframe.contentDocument, null);
    t.done();
  };
  document.body.appendChild(iframe);
}, "Test redirects to data URLs are blocked.");

async_test(t => {
  var iframe = document.createElement('iframe');
  iframe.src = '/resources/redirect.php?url=file:///var/foo';
  iframe.onload = () => {
    assert_equals(iframe.contentDocument, null);
    t.done();
  };
  document.body.appendChild(iframe);
}, "Test redirects to file URLs are blocked.");

if (window.webkitRequestFileSystem) {
  async_test(t => {
    var blob = new Blob(['<html><body>hello</body></html>'],
                        {type: 'text/html'});
    window.webkitRequestFileSystem(TEMPORARY, blob.size, fs => {
      fs.root.getFile('foo.html', {create: true}, file => {
        file.createWriter(writer => {
          writer.write(blob);
          writer.onwriteend = () => {
            var iframe = document.createElement('iframe');
            iframe.src = '/resources/redirect.php?url=' + file.toURL();
            iframe.onload = () => {
              assert_equals(iframe.contentDocument, null);
              t.done();
            };
            document.body.appendChild(iframe);
          }
        });
      });
    });
  }, "Test redirects to filesystem URLs are blocked.");
}
</script>
</body>
</html>
